"""
用户数据访问
"""
from entity.userModel import User
from util import dbUtil

currentUser:User = None

def login(user:User):
    """
    用户登录判断
    :param user:
    :return: 登录成功后返回实体
    """
    con = None
    try:
        con = dbUtil.getCon()
        cursor = con.cursor()
        result = cursor.execute(f"select id,username,password from t_user where username='{user.username}' and password='{user.password}'")
        return cursor.fetchone()
    except Exception as e:
        con.rollback()
    finally:
        dbUtil.closeCon(con)
